refactor: extract duplicated alert command execution paths#281
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #278 by extracting two duplicated command execution code blocks within syslog_process_alert() into shared helper functions in functions.php, reducing maintenance risk and preventing future divergence between the two branches. A regression test validates the refactoring structure.
Changes:
- Introduces
syslog_execute_ticket_command()andsyslog_execute_alert_command()as shared helpers infunctions.php, replacing two near-identical inline blocks in each branch ofsyslog_process_alert(). - Adds a regression test (
issue278_command_execution_refactor_test.php) that uses string-matching onfunctions.phpto verify helper presence and call-site count. - Updates
CHANGELOG.mdwith issue #278 entry.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
functions.php |
Adds two new helper functions above syslog_process_alerts() and replaces the two duplicated inline command blocks at the call sites |
tests/regression/issue278_command_execution_refactor_test.php |
New regression test verifying helpers exist and are called from both branches via text-based string matching |
CHANGELOG.md |
Adds changelog entry for issue #278 |
|
Fixed in 70b2147 -- added PHPDoc blocks to both execute helpers matching the existing convention; narrowed the test assertion from the broad prefix to the full call-site signature (including trailing |
f7966e5 to
a14e876
Compare
|
@somethingwithproof more conflicts with the ChangeLog. I like this change. |
TheWitness
left a comment
There was a problem hiding this comment.
Good change. Fix the changelog merge conflicts and this one is okay.
9ed829f to
31d898e
Compare
|
Rebased and CHANGELOG conflicts resolved. |
Refs Cacti#281 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
31d898e to
c8fd4cc
Compare
5945930 to
c8fd4cc
Compare
Refs Cacti#281 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
c8fd4cc to
03eaf85
Compare
Refs Cacti#281 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
03eaf85 to
f371223
Compare
Summary
Fixes #278
Validation